<?php
namespace app\m\controller;

use app\common\controller\FrontController;
use app\common\service\MemberService;

class Cart extends FrontController
{
    public function cart_change(){
        $cartId = input('cart_id');
        $total = input('total');
        $memberService = new MemberService();
        $jieguo = $memberService->updateCartTotalById($this->getMemberId(),$cartId,$total);
        if($jieguo['err_code'] != 0){
            $this->error($jieguo['msg']);
        }
        else{
            $this->success('更新成功');
        }
    }

    public function del_cart(){
        $ids = input('cart_ids');
        $memberService = new MemberService();
        $jieguo = $memberService->delCartByIds($this->getMemberId(),explode(',', $ids));
        if($jieguo['err_code'] != 0){
            $this->error($jieguo['msg']);
        }
        else{
            $this->success('删除成功');
        }
    }
}
